#include "gtest/gtest.h"

#include "base.h"
#include "OptionsArgs.h"


TEST(SliceTest, test){
    std::string str = "hello world";
    helper::demo::Slice s(str);

    ASSERT_EQ(str, std::string(s.data(), s.size()));
}
TEST(StatusTest, test){
    helper::demo::Status s;
    ASSERT_TRUE(s.ok());
}



TEST(OptionsTest, test){
  using OptionsArgs = helper::demo::OptionsArgs;
  {
    auto && optargs = OptionsArgs::create();
    (void)optargs;
  }

  using DBOptions = helper::demo::DBOptions;
  {
    auto && optargs = OptionsArgs::create(DBOptions());
    (void)optargs;
  }

  using ReadOptions = helper::demo::ReadOptions;
  using WriteOptions = helper::demo::WriteOptions;
  {
    auto && optargs = OptionsArgs::create(DBOptions(), ReadOptions(), WriteOptions());
    (void)optargs;
  }

  using ColumnFamilyOptions = helper::demo::ColumnFamilyOptions;
  {
    auto && optargs = OptionsArgs::create(DBOptions(), ReadOptions(), WriteOptions(), ColumnFamilyOptions());
    (void)optargs;
  }

  {
    const auto && optargs = OptionsArgs::create(DBOptions(), ReadOptions(), WriteOptions(), ColumnFamilyOptions());

    optargs.database();
    optargs.columnFamily();
    optargs.read();
    optargs.write();
    optargs.open();
  }
  {
    auto && optargs = OptionsArgs::create(DBOptions(), ReadOptions(), WriteOptions(), ColumnFamilyOptions());
    optargs.database().create_if_missing = true;
    ASSERT_EQ(optargs.open().create_if_missing, optargs.database().create_if_missing);

    optargs.columnFamily().write_buffer_size = 1024 * 1024;
    ASSERT_EQ(optargs.open().write_buffer_size, optargs.columnFamily().write_buffer_size);

    optargs.open().create_if_missing = false;
    ASSERT_EQ(optargs.open().create_if_missing, optargs.database().create_if_missing);

    optargs.read().iter_start_seqnum  = optargs.read().iter_start_seqnum;

    optargs.write().sync = true;
  }
}


